if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_ChiTietNhapXuat_GetByMaPhieuNhapXuat]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_ChiTietNhapXuat_GetByMaPhieuNhapXuat]
GO
CREATE PROC [sp_ChiTietNhapXuat_GetByMaPhieuNhapXuat](
	@MaPhieuNhapXuat				INT
)
AS
BEGIN
	SELECT
		A.ID,
		A.Ma_phieu_nhap_xuat,
		A.Ma_hang_hoa,
		B.Ma_hang AS 'Ky_hieu_hang',
		B.Ten AS 'Ten_hang',
		A.Ghi_chu,
		A.So_luong,
		A.Gia,
		A.Thanh_tien,
		A.Thue,
		A.Tien_thue,
		A.Tong_tien,
		A.Chiet_khau,
		A.Tien_chiet_khau,
		A.Han_su_dung,
		A.Bao_hanh,
		A.Phi_van_chuyen,
		A.So_luong_goc,
		A.Ngay_cap_nhat_cuoi
	FROM ChiTietNhapXuat AS A
	INNER JOIN HangHoa AS B ON A.Ma_hang_hoa = B.ID
	WHERE A.Ma_phieu_nhap_xuat = @MaPhieuNhapXuat
END
